package nameless.aistudy.domain.service.subjects.english.vocabulary.impl;

import nameless.aistudy.common.util.ai.AIUtil;
import nameless.aistudy.domain.model.subjects.english.vocabulary.word.Word;
import nameless.aistudy.domain.service.subjects.english.vocabulary.VocabularyAIService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

@Service
public class VocabularyAIServiceImpl implements VocabularyAIService {
    @Autowired
    AIUtil aiUtil;

    private record WordRecord(
            String ukPronunciationIpa,
            String usPronunciationIpa,
            String memoryTechnique
    ) {}

    public Word fillWordBySpell(String spell) {
        WordRecord wordRecord = aiUtil.buildChatClient(256, 0.0)
                .prompt()
                .system("极简回答")
                .user(spell + "的词汇信息，记忆技巧适合中文母语者")
                .call()
                .entity(WordRecord.class);

        Word word = new Word(spell);
        BeanUtils.copyProperties(wordRecord, word);
        word.setAssociationTips(wordRecord.memoryTechnique());

        return word;
    }
}
